<?php

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the Closure to execute when that URI is requested.
|
*/

/* Manager Routes */
Route::get(	'manager/',  		array('as' => 'manager.dashboard.index',	'uses' => 'App\Controllers\Manager\DashboardController@index'));
Route::get(	'manager/logout',  	array('as' => 'manager.logout',      		'uses' => 'App\Controllers\Manager\AuthController@getLogout'));
Route::get(	'manager/create',  	array('as' => 'manager.create',      		'uses' => 'App\Controllers\Manager\AuthController@getCreate'));
Route::get(	'manager/login',   	array('as' => 'manager.login',				'uses' => 'App\Controllers\Manager\AuthController@getLogin'));
Route::post('manager/login',  	array('as' => 'manager.login.post',			'uses' => 'App\Controllers\Manager\AuthController@postLogin'));
Route::post('manager/create',  	array('as' => 'manager.create.post',		'uses' => 'App\Controllers\Manager\AuthController@postCreate'));

Route::group(array('prefix' => 'manager', 'before' => 'auth.manager'), function()
{
	// Default
	Route::any(		'/', 						'App\Controllers\Manager\DashboardController@index');
	
	// Pages
	Route::resource('pages', 					'App\Controllers\Manager\PagesController');
	Route::post(	'/pages/move', 				'App\Controllers\Manager\PagesController@move');
	Route::get(		'/pages/quickedit/{id}', 	'App\Controllers\Manager\PagesController@getQuickEdit');
	Route::get(		'/pages/makehomepage/{id}', 	'App\Controllers\Manager\PagesController@makeHomepage');
	Route::post(	'/pages/quickedit', 		'App\Controllers\Manager\PagesController@saveQuickEdit');
	Route::post(	'/pages/getslug', 		'App\Controllers\Manager\PagesController@getSlug');

	// Products
	Route::resource('products',										'App\Controllers\Manager\ProductsController');
	Route::post(	'/products/getslug', 							'App\Controllers\Manager\ProductsController@getSlug');
	Route::post(	'/products/uploadimage/{productid}',			array('as' => "manager.products.uploadimage", "uses" => "App\Controllers\Manager\ProductsController@uploadImage"));
	Route::get(		'/products/deleteimage/{productid}/{imageid}',	array('as' => "manager.products.deleteimage", "uses" => "App\Controllers\Manager\ProductsController@deleteImage"));
	Route::get(		'/products/getimages/{productid}',				array('as' => "manager.products.getimages", "uses" => "App\Controllers\Manager\ProductsController@getImages"));
	Route::post(	'/products/uploadfile/{productid}',				array('as' => "manager.products.uploadfile", "uses" => "App\Controllers\Manager\ProductsController@uploadFile"));
	Route::get(		'/products/deletefile/{productid}/{fileid}',	array('as' => "manager.products.deletefile", "uses" => "App\Controllers\Manager\ProductsController@deleteFile"));
	Route::get(		'/products/getfiles/{productid}',				array('as' => "manager.products.getfiles", "uses" => "App\Controllers\Manager\ProductsController@getFiles"));
    Route::post(	'/products/saverelatedproducts', 				'App\Controllers\Manager\ProductsController@saveRelatedProducts');
	
	// Product Categories
	Route::resource('productcategories',										'App\Controllers\Manager\ProductCategoriesController');
	Route::post(	'/productcategories/move', 				'App\Controllers\Manager\ProductCategoriesController@move');
	Route::post(	'/productcategories/getslug', 		'App\Controllers\Manager\ProductCategoriesController@getSlug');

	// Product Image Types
	Route::resource('productimagetypes',	'App\Controllers\Manager\ProductImageTypesController');

	// Product File Types
	Route::resource('productfiletypes',		'App\Controllers\Manager\ProductFileTypesController');
	
	// Projects
	Route::resource('projects',										'App\Controllers\Manager\ProjectsController');
	Route::post(	'/projects/getslug', 							'App\Controllers\Manager\ProjectsController@getSlug');
	Route::post(	'/projects/uploadimage/{projectid}',			array('as' => "manager.projects.uploadimage", "uses" => "App\Controllers\Manager\ProjectsController@uploadImage"));
	Route::get(		'/projects/deleteimage/{projectid}/{imageid}',	array('as' => "manager.projects.deleteimage", "uses" => "App\Controllers\Manager\ProjectsController@deleteImage"));
	Route::get(		'/projects/getimages/{projectid}',				array('as' => "manager.projects.getimages", "uses" => "App\Controllers\Manager\ProjectsController@getImages"));
	Route::post(	'/projects/uploadfile/{projectid}',				array('as' => "manager.projects.uploadfile", "uses" => "App\Controllers\Manager\ProjectsController@uploadFile"));
	Route::get(		'/projects/deletefile/{projectid}/{fileid}',	array('as' => "manager.projects.deletefile", "uses" => "App\Controllers\Manager\ProjectsController@deleteFile"));
	Route::get(		'/projects/getfiles/{projectid}',				array('as' => "manager.projects.getfiles", "uses" => "App\Controllers\Manager\ProjectsController@getFiles"));

    // News
	Route::resource('news',										'App\Controllers\Manager\NewsController');
	Route::post(	'/news/getslug', 							'App\Controllers\Manager\NewsController@getSlug');
	Route::post(	'/news/uploadimage/{newsid}',			array('as' => "manager.news.uploadimage", "uses" => "App\Controllers\Manager\NewsController@uploadImage"));
	Route::get(		'/news/deleteimage/{newsid}/{imageid}',	array('as' => "manager.news.deleteimage", "uses" => "App\Controllers\Manager\NewsController@deleteImage"));
	Route::get(		'/news/getimages/{newsid}',				array('as' => "manager.news.getimages", "uses" => "App\Controllers\Manager\NewsController@getImages"));

	// Videos
	Route::resource('videos',										'App\Controllers\Manager\VideosController');
	Route::post(	'/videos/getslug', 							'App\Controllers\Manager\VideosController@getSlug');// Videos

	// Jobs
	Route::resource('jobs',										'App\Controllers\Manager\JobsController');
	Route::post(	'/jobs/getslug', 							'App\Controllers\Manager\JobsController@getSlug');
	Route::post(	'/jobs/uploadfile/{jobid}',				array('as' => "manager.jobs.uploadfile", "uses" => "App\Controllers\Manager\JobsController@uploadFile"));
	Route::get(		'/jobs/deletefile/{jobid}/{fileid}',	array('as' => "manager.jobs.deletefile", "uses" => "App\Controllers\Manager\JobsController@deleteFile"));
	Route::get(		'/jobs/getfiles/{jobid}',				array('as' => "manager.jobs.getfiles", "uses" => "App\Controllers\Manager\JobsController@getFiles"));

});

/* Frontend Routes */

Route::any("{params?}", 'App\Controllers\Frontend\PageController@getPage')->where("params", "[A-Za-z0-9\/\-\_]+");
/*
Route::get('{params?}', function($params = "none")
{
	return View::make('frontend.page', array("slug"=>"", "params"=>$params));
})->where("params", "[A-Za-z0-9\/]+");

Route::get('{slug}/{params?}', function($slug = "home", $params = "")
{
	return View::make("frontend.page", array("slug"=>$slug, "params"=>$params));
})->where("params", "[A-Za-z0-9\/]+");
*/
